import store from '../store'

const permissionRule = {

  rescueCompany: {
    listOperationRescueCompany: 'admin:rescue:company:operation:list',
    removeRescueCompany: 'admin:rescue:company:delete',
    getOperationById: 'admin:rescue:company:operation:get:*',
    updateRole: 'admin:rescue:company:update:role'
  },

  workOrder: {
    listOperationWorkOrder: 'admin:worksheets:operation:list',
    listWorkOrder: 'admin:worksheets:list',
    workOrderOperationView: 'admin:worksheets:operation:view:*',
    removeOperationElectronicWorksheets: 'admin:worksheets:operation:delete',
    exportExcel: 'admin:worksheets:operation:export:excel',
    exportPdf: 'admin:worksheets:operation:export:pdf:*',
    setWorktemplate: 'admin:rescue:company:set:worktemplate:*',
    updateRescueCompany: 'admin:rescue:company:update:*'
  },

  electronicWorksheetsTemplate: {
    listAllElectronicWorksheetsTemplate: '/admin/worksheets/template/list/all',
    listElectronicWorksheetsTemplate: '/admin/worksheets/template/list',
    addElectronicWorksheetsTemplate: 'admin:worksheets:template:add',
    getElectronicWorksheetsTemplate: '/admin/worksheets/template/get/',
    updateElectronicWorksheetsTemplate: 'admin:worksheets:template:update:*',
    updateUseRange: 'admin:worksheets:template:update:userange:*',
    removeElectronicWorksheetsTemplate: 'admin:worksheets:template:delete'
  },

  onlineServiceCompany: {
    listAllOnlineServiceCompany: '/admin/online/service/company/list/all',
    listOnlineServiceCompany: '/admin/online/service/company/list',
    addOnlineServiceCompany: 'admin:online:service:company:add',
    getOnlineServiceCompany: '/admin/online/service/company/get/',
    updateOnlineServiceCompany: 'admin:online:service:company:update:*',
    setWorkTemplate: 'admin:online:service:company:set:worktemplate:*',
    removeOnlineServiceCompany: 'admin:online:service:company:delete'
  },

  rescueEmployee: {
    auditRescueCompanyManager: 'admin:rescue:company:employee:audit:manager:*',
    auditRescueCompanyDriver: 'admin:rescue:company:employee:audit:driver:*',
    againApplyRescueCompanyDriver: 'admin:rescue:company:employee:again:apply:driver:*',
  },

  organization: {
    listOrganization: '/admin/organization/list',
    addOrganization: 'admin:organization:add',
    getOrganizationById: '/admin/organization/get/',
    updateOrganization: 'admin:organization:update:*',
    removeOrganization: 'admin:organization:delete'
  },

  organization2role: {
    listRoleSelectd: '/admin/list/organization/role/selected',
    listRoleNoSelectd: '/admin/list/organization/role/noselected/',
    updateOrganizationRole: 'admin:organization:role:add'
  },

  user: {
    listUser: '/admin/user/list',
    addUser: 'admin:user:add',
    getUserById: '/admin/user/get/',
    updateUser: 'admin:user:update:*',
    updatePassword: 'admin:user:resetpassword',
    removeUser: 'admin:user:delete',
    uploadHeadImgUrl: '/admin/user/upload',
    pUpdateUser: '/admin/user/info/update',
    pUpdatePassword: '/admin/user/info/resetpassword',
  },

  user2role: {
    listAllRoleSelectd: '/admin/list/all/role/selected/',
    saveUser2Role: 'admin:user2role:add'
  },

  role: {
    listAllRole: '/admin/role/list/all',
    listRole: '/admin/role/list',
    addRole: 'admin:role:add',
    getRoleById: '/admin/role/get/',
    updateRole: 'admin:role:update:*',
    removeRole: 'admin:role:delete',
    listAgentsAllRole: '/admin/role/list/agents/all'
  },

  module: {
    listAllModule: '/admin/module/list/all',
    listModule: '/admin/module/list',
    addModule: '/admin/module/add',
    getModuleById: '/admin/module/get/',
    updateModule: '/admin/module/update/',
    removeModule: '/admin/module/delete',
  },

  operation: {
    listAllOperation: '/admin/operation/list/all',
    listOperation: '/admin/operation/list/',
    addOperation: '/admin/operation/add',
    getOperationById: '/admin/operation/get/',
    updateOperation: '/admin/operation/update/',
    removeOperation: '/admin/operation/delete',
  },
  menu: {
    listAllMenu: '/admin/menu/list/all'
  },
  permission: {
    listAllPermission: '/admin/list/permission/all',
    listPermissionSelectd: '/admin/list/permission/selected/',
    listPermissionNoSelectd: '/admin/list/permission/noselected/',
    savePermission: 'admin:permission:add',
    removePermission: '/admin/permission/delete',
    reloadPermission: '/admin/permission/reload'
  },

  sysInfo: {
    getCompanyInfo: '/admin/sys/info/company/get',
    updateCompanyInfo: '/admin/sys/info/company/update',
    deleteSysInfo: '/admin/sys/info/delete/',
    getSlideList: '/admin/sys/info/slide/list/0',
    getPosterList: '/admin/sys/info/slide/list/6',
    updateSlideStatus: '/admin/sys/info/status'
  },
  dictionary: {
    listAll: '/admin/dictionary/list/all',
    listAllDictory: '/admin/dictionary/list/all/',
    listDictory: '/admin/dictionary/list',
    saveDictory: 'admin:dictionary:add',
    getDictory: '/admin/dictionary/get/',
    updateDictory: 'admin:dictionary:update:*',
    removeDictory: 'admin:dictionary:delete'
  },
  industry: {
    list: 'admin:industry:list',
    add:'admin:industry:add',
    update:'admin:industry:update',
    del:'admin:industry:del',
    load:'admin:industry:load:id:*',
    batchDel:'admin:industry:batchDel'
  },
  arbitration: {
    list: 'admin:arbitration:list',
    del:'admin:arbitration:del',
    load:'admin:arbitration:load:id:*',
    handle:'admin:arbitration:changeState',
    changeState:'admin:arbitration:changeState',
  },
  transportConfirm:{
    list:'admin:ransportConfirm:list',
    del:'admin:transportConfirm:del',
    load:'admin:transportConfirm:load:id:*'
  },
  protocol: {
    list: 'admin:protocol:list',
    add:'admin:protocol:add',
    update:'admin:protocol:update',
    del:'admin:protocol:del',
    load:'admin:protocol:load:id:*'
  },
}

function validAction(rule) {
  const roles = store.getters.roles
  return roles.indexOf(rule) != -1
}

export default {
  permissionRule,
  validAction
}
